$(function(){
		$.ajax({
			url:'http://localhost:8080/deskserver/sw/getMenusJson',
			type : "GET",
			dataType:"json",
			contentType : "application/json;charset=utf-8",
			success:function(data){
				
				var jsonObj = data;
							
				var htmlArr = [];
	 			
	 			for(var i=0;i<jsonObj.length;i++){
	 				htmlArr.push('<div class="modules">');
	 				htmlArr.push('<div class="title">');
	 				htmlArr.push(jsonObj[i].menuText);
	 				htmlArr.push('</div>');
	 				var menuList = jsonObj[i].children;
	 				for(j=0;j<menuList.length;j++){
	 					htmlArr.push('<div class="menu">');
	 					if(menuList[j].menuId){//有menu_id取menu_id
	 						htmlArr.push('<a href="javascript:void(0)" menu-id="'+menuList[j].menuId+'">'+menuList[j].menuText+'</a>');
	 					}else{ //无menu_id取 href
	 						htmlArr.push('<a href="'+menuList[j].href+'">'+menuList[j].menuText+'</a>');
	 					}
	 					htmlArr.push('</div>');	
	 				}
	 				htmlArr.push('</div>');
	 			}
	 			$("#menublock").html(htmlArr.join(""));
	 			
	 			//点击事件
	 			$(".modules .menu").click(function(){
		 	    	var url = location.origin+location.pathname;
		 	     
		 	        location.href=url+"?menu_id="+$(this).children("a").attr("menu-id");
		 	        
		 	    });
			},
			error:function(request,err){
				alert(request);
				alert(err);
			}
		});
 		 	    
	});